package com.qige.homework;

import java.util.Scanner;

public class JavaSE3 {
    public static void main(String[] args) {
        TV tv = new TV("海尔");
        RemoteControl remoteControl = new RemoteControl();
        remoteControl.controlTV(tv);
        System.out.println("==============================");
        Phone phone = new Phone();
        phone.connecting();
        phone.controlTV(tv);
    }
}
class TV{
    public String name;

    public TV() {
    }

    public TV(String name) {
        this.name = name;
    }
    public void play(String channel ){
        System.out.println(name + " 电视正在播放"+ channel +"节目");
    }
}
interface RedRay{
    void controlTV(TV tv);
    default void connecting(){
        System.out.println("外接设备,连接成功, 可以使用红外线");
    }
}
class RemoteControl{
    public void controlTV(TV tv){
        System.out.println("遥控器控制电视");
        System.out.println("请输入节目名称:");
        Scanner input = new Scanner(System.in);
        String channel = input.next();
        tv.play(channel);
    }
}
class Phone implements RedRay{

    @Override
    public void controlTV(TV tv) {
        System.out.println("手机开启红外功能,控制电视");
        System.out.println("请输入节目名称:");
        Scanner input = new Scanner(System.in);
        String channel = input.next();
        tv.play(channel);
    }
}